<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script type="text/javascript">

    var book = {}
    Object.defineProperties(book, {
        year: {
            writable: true,
            value: 2020
        },
        name: {
            writable: false,
            value: '人间值得'
        },
        color: {
            configurable: false,
            value: 'black'
        },
        date: {
            get: function () {
                return this.year
            },
            set: function (v) {
                if (v > 2020) {
                    this.year = v
                } else {
                    this.year = 2020
                }
            }
        }
    })

    var result = Object.getOwnPropertyDescriptor(book, "name")
    console.log(result)
    var dateResult = Object.getOwnPropertyDescriptor(book, "date")
    console.log(dateResult)

</script>

</body>
</html>
